﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using SqlServerWrapper;
using NCrawler.Extensions;

namespace ZCrawler
{
    public class ZSQLPublisher : ZPublisher
    {
        public string server { get; set; }
        public string database { get; set; }
        public string table_name { get; set; }
        public string connection_login_id{get;set;}
        public string connection_login_pass{get;set;}
        public string sql_command_text { get; set; }
        public CommandType sql_command_type { get; set; }
        public SqlConnection MakeConnection()
        {
            SqlConnection conn = SqlConnectionManager.CreateSqlConnection(GenerateConnectionString());
            return conn;
        }

        private string GenerateConnectionString()
        {
            return "Data Source={0};Initial Catalog={1};User ID={2};Password={3}"
                .FormatWith(server, database, connection_login_id, connection_login_pass);
        }
    }
}
